import java.awt.Point;
import java.awt.Rectangle;
import java.util.ArrayList;


public class Move implements Comparable<Object>{
	
	public Gem gem1;
	public Gem gem2;
	public int points;
	
	public ArrayList<Rectangle> effectAreas;
	
	public Move(Gem _gem1, Gem _gem2) {
		gem1 = _gem1;
		gem2 = _gem2;
		points = 0;
		effectAreas = new ArrayList<Rectangle>(2);
	}
	
	public boolean equals(Object _move) {
		if(_move == null)
			return false;
		Move move = (Move) _move;
		if(move.gem1.equals(gem1) && move.gem2.equals(gem2))
			return true;
		if(move.gem1.equals(gem2) && move.gem2.equals(gem1))
			return true;
		return false;
	}
	
	public String toString() {
		return gem1.toString() + " by " + gem2.toString();
	}

	public int compareTo(Object _move) {
		if(_move == null)
			return 1;
		Move move = (Move) _move;
		if(points > move.points)
			return 1;
		if(points == move.points)
			return 0;
		if(points < move.points)
			return -1;
		return 0;
	}

	public void AddEffectArea(int startX, int startY, int endX, int endY, boolean horiz) {
		if(horiz) {
			effectAreas.add(new Rectangle(startX, 0, (endX - startX) + 1, endY+1));
		} else {
			effectAreas.add(new Rectangle(startX, 0, startX + 1, endY + 1));
		}
	}
	
	public boolean EffectAreasContainPoint(Point p) {
		for(int i=0; i<effectAreas.size(); i++)
			if(effectAreas.get(i).contains(p))
				return true;
		return false;
	}
}
